using System;
using System.Collections.Generic;
using UnityEngine;

public class ShopLayer : UILayer
{
	public enum TabEnum
	{
		Shoes = 0,
		Coins = 1,
		Dollars = 2
	}

	[Serializable]
	public class TabDesc
	{
		public TabEnum type;

		public UITabButton tab;
	}

	public List<TabDesc> tabDesc = new List<TabDesc>();

	protected UITabController mTabController;

	protected bool started;

	public static ShopLayer instance { get; protected set; }

	private void Start()
	{
		Debug.Log("Showing Shop Layer");
		if (!started)
		{
			instance = this;
			mTabController = GetComponent<UITabController>();
			started = true;
		}
	}

	private void OnEnable()
	{
		Debug.Log("Hiding banner");
		Ads.instance.hideBanner(true);
	}

	private void OnDisable()
	{
		Ads.instance.hideBanner(false);
	}

	private void OnDestroy()
	{
		instance = null;
	}

	public void ShowTab(TabEnum desc)
	{
		foreach (TabDesc item in tabDesc)
		{
			if (item.type == desc)
			{
				if (!started)
				{
					Start();
				}
				mTabController.SelectTab(item.tab);
				break;
			}
		}
	}

	public void ShowShopTab()
	{
		ShowTab(TabEnum.Coins);
	}
}
